function getParentPath(path: string | undefined): string | undefined {
  if (!path) {
    return path;
  }
  let seperator = "/";
  if (!path.startsWith(seperator)) {
    seperator = "\\";
  }

  return path.substring(0, path.lastIndexOf(seperator));
}

function getNodeName(path: string | undefined): string | undefined {
  if (!path) {
    return path;
  }
  let seperator = "/";
  if (!path.startsWith(seperator)) {
    seperator = "\\";
  }

  return path.substring(path.lastIndexOf(seperator) + 1);
}

function highLightSearchKeyword(content?: string, keyword?: string): string {
  if (!content || !keyword) {
    return "";
  }
  return content.replace(keyword, `<span style="background-color: rgb(245, 219, 77);">${keyword}</span>`)
}

export { getParentPath, getNodeName ,highLightSearchKeyword};
